package com.example.lenovo.demo.presenter.listener;

import android.app.ProgressDialog;
import android.content.Context;
import android.util.Log;
import android.widget.ListView;

import com.example.lenovo.demo.model.Model;
import com.example.lenovo.demo.model.databean.StrategyBean;
import com.example.lenovo.demo.model.idatabean.IModel;
import com.example.lenovo.demo.model.idatabean.OnStrategySuccess;
import com.example.lenovo.demo.presenter.adapter.StrategyAcLvAdapter;
import com.example.lenovo.demo.view.ifgview.IStrategyActivity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Lenovo on 2017/1/14.
 */

public class StrategyActivityPresenter implements IStrategyActivity{
    private Context context;
    private ListView listView;
    private String id;
    private ProgressDialog progressDialog;
    private IModel iModel;
    private StrategyAcLvAdapter acLvAdapter;
    private List<StrategyBean> data;

    public void initData(){
        progressDialog.show();
        data=new ArrayList<>();
        acLvAdapter =new StrategyAcLvAdapter(data,context);
        iModel=new Model();
        iModel.sendStrategyBean(id, new OnStrategySuccess() {
            @Override
            public void StrategySuccess(List<StrategyBean> strategyBeans) {
                data.addAll(strategyBeans);
                listView.setAdapter(acLvAdapter);
                progressDialog.dismiss();
            }

            @Override
            public void StrategyFaild() {

            }
        });
    }


    @Override
    public void sendView(Context context, ListView listView, String id, ProgressDialog progressDialog) {
        this.context=context;
        this.listView=listView;
        this.id=id;
        this.progressDialog=progressDialog;
    }
}
